echo "Current build&Create $1"

build_done=0

if [ $1 = uboot ]
then
cd tool/bootloader/imx-bootlets-src-10.12.01/
rm ./u-boot
rm ./imx28_ivt_uboot.sb
cd ../../../

cd u-boot-2015.10-rc1/
export CROSS_COMPILE=arm-fsl-linux-gnueabi-
export ARCH=arm
make mx28evk_nand_config
make
cd ../

cd tool/bootloader/imx-bootlets-src-10.12.01/
cp ../../../u-boot-2015.10-rc1/u-boot ./
./build
cp imx28_ivt_uboot.sb ../../../output/
cp imx28_ivt_uboot.sb /mnt/EasyARM_V1.03/image/
build_done=1
fi

if [ $1 = rootfs ]
then
cd rootfs
sudo mkfs.ubifs -r rootfs  -m 2048 -e 126976 -c 864 -o ubifs.img
sudo ubinize -o ubi.img -m 2048 -p 128KiB -s 512 ubinize.cfg
mv ubifs.img ../output/rootfs.ubifs
cp ../output/rootfs.ubifs /mnt/EasyARM_V1.03/image/
cd ../
build_done=1
fi


if [ $1 = kernel ]
then
cd linux-2.6.35.3/
make uImage
cp arch/arm/boot/uImage ../output/
cp arch/arm/boot/uImage /mnt/EasyARM_V1.03/image/
build_done=1
fi

if [ $build_done -ne 1 ]
then
echo "no find rule $1"
fi

echo "Build $1 finish"